
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>后台</title>
<link rel="stylesheet" href="public/admin/dashicons.css">
<link rel="stylesheet" href="public/admin/style.css">
<script src="public/admin/jquery.min.js"></script>
</head>
<body>
<div class="wrap wrap-category">
<h1>栏目管理</h1>
<div class="tips"></div>
<div class="box">
<div class="box-body">
	<form method="post" action="/?p=admin&c=category&token=c15a2f6833d839516c2d95b4ce48456b">
	<table>
		<tr><th width="84">显示顺序</th><th>栏目名称</th><th width="120">操作</th></tr>
		<!-- 顶级栏目 -->
					<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[1][sort]" value="0"></td>
			  <td><input type="text" name="save[1][name]" value="PHP"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=1&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
			<!-- 子级栏目 -->
						<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[8][sort]" value="0"></td>
			  <td><i class="icon-sub"></i><input type="text" name="save[8][name]" value="MySQL"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=8&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
						<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[9][sort]" value="1"></td>
			  <td><i class="icon-sub"></i><input type="text" name="save[9][name]" value="PHP基础"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=9&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
						<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[10][sort]" value="2"></td>
			  <td><i class="icon-sub"></i><input type="text" name="save[10][name]" value="PHP高级"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=10&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
						<tr><td colspan="3"><i class="icon-sub-add"></i><span class="jq-sub-add s-add" data-id="1"><i class="icon-cross"></i><b>添加子栏目</b></span></td></tr>
					<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[2][sort]" value="1"></td>
			  <td><input type="text" name="save[2][name]" value="Java"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=2&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
			<!-- 子级栏目 -->
						<tr><td colspan="3"><i class="icon-sub-add"></i><span class="jq-sub-add s-add" data-id="2"><i class="icon-cross"></i><b>添加子栏目</b></span></td></tr>
					<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[3][sort]" value="2"></td>
			  <td><input type="text" name="save[3][name]" value="iOS"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=3&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
			<!-- 子级栏目 -->
						<tr><td colspan="3"><i class="icon-sub-add"></i><span class="jq-sub-add s-add" data-id="3"><i class="icon-cross"></i><b>添加子栏目</b></span></td></tr>
					<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[4][sort]" value="3"></td>
			  <td><input type="text" name="save[4][name]" value="UI设计"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=4&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
			<!-- 子级栏目 -->
						<tr><td colspan="3"><i class="icon-sub-add"></i><span class="jq-sub-add s-add" data-id="4"><i class="icon-cross"></i><b>添加子栏目</b></span></td></tr>
					<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[5][sort]" value="4"></td>
			  <td><input type="text" name="save[5][name]" value="前端与移动开发"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=5&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
			<!-- 子级栏目 -->
						<tr><td colspan="3"><i class="icon-sub-add"></i><span class="jq-sub-add s-add" data-id="5"><i class="icon-cross"></i><b>添加子栏目</b></span></td></tr>
					<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[6][sort]" value="5"></td>
			  <td><input type="text" name="save[6][name]" value="C/C++"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=6&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
			<!-- 子级栏目 -->
						<tr><td colspan="3"><i class="icon-sub-add"></i><span class="jq-sub-add s-add" data-id="6"><i class="icon-cross"></i><b>添加子栏目</b></span></td></tr>
					<tr class="hover">
			  <td class="center"><input type="text" class="s-num" name="save[7][sort]" value="6"></td>
			  <td><input type="text" name="save[7][name]" value="Python"></td>
			  <td class="center"><a href="/?p=admin&c=category&exec=del&id=7&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			</tr>
			<!-- 子级栏目 -->
						<tr><td colspan="3"><i class="icon-sub-add"></i><span class="jq-sub-add s-add" data-id="7"><i class="icon-cross"></i><b>添加子栏目</b></span></td></tr>
				<tr><td colspan="3"><span class="jq-add s-add"><i class="icon-cross"></i><b>添加新栏目</b></span></td></tr>
		<tr class="s-act"><td colspan="3"><input type="submit" value="提交更改"></td></tr>
	</table>
	</form>
</div>
</div>
</div>
<script>
	var add_id = 0; //保存ID计数
	//添加新栏目
	$(".jq-add").click(function(){
		$(this).parents("tr").before('<tr class="hover"><td class="center">\
		<input type="text" class="s-num" name="add[' + add_id + '][sort]"></td><td colspan="2">\
		<input type="text" name="add[' + add_id + '][name]">\
		<input type="hidden" name="add[' + add_id + '][pid]" value="0">\
		<b class="jq-cancel">取消</b></td></tr>');
		++add_id;
	});
	//添加子栏目
	$(".jq-sub-add").click(function(){
		var id = $(this).attr("data-id");		
		$(this).parents("tr").before('<tr class="hover"><td class="center">\
		<input type="text" class="s-num" name="add[' + add_id + '][sort]"></td><td colspan="2">\
		<i class="icon-sub"></i><input type="text" name="add[' + add_id + '][name]">\
		<input type="hidden" name="add['+add_id+'][pid]" value="' + id + '">\
		<b class="jq-cancel">取消</b></td></tr>');
		++add_id;
	});
	//取消添加
	$(document).on("click",".jq-cancel",function(){
		$(this).parents("tr").remove();
	});
	//删除前提示
	$(".jq-del").click(function(){
		return confirm("您确定要删除此栏目？");
	});
</script>
</body>
</html>